!/bin/sh
#
# Start or stop system wide mpd daemon
# Source the aved functions
. /etc/profile.d/aved.sh
case "$1" in
start)
# This assumes only nodes and not the master are listed in the mpd.hosts file
# because the master is not typically listed as a worker node
c=`wc -l $MPDIR/etc/mpd.hosts | awk '{print $1}'`
# Add one to include the master
((c += 1))
if [ ! -e '/tmp/mpd2.console_root' ]; then
mpdboot --ncpus=4 --totalnum=$c --file="$MPDIR/etc/mpd.hosts --mpd=$MPDIR/bin/mpd.py"
else
echo "restarting mpd"
mpdallexit
mpdboot --ncpus=4 --totalnum=$c --file="$MPDIR/etc/mpd.hosts --mpd=$MPDIR/bin/mpd.py"
fi
mpdtrace
;;
stop)
if [ -e '/tmp/mpd2.console_root' ]; then
mpdallexit
#remove tmp file in case mpdallexit cmd fails
if [ -e '/tmp/mpd2.console_root' ]; then
rm /tmp/mpd2.console_root
fi
echo "mpd daemon stopped"
else
echo "mpd daemon already stopped"
fi
;;
status)
if [ -e '/tmp/mpd2.console_root' ]; then
mpdtrace -l
else
echo "mpd daemon not running"
fi
;;
*) echo "usage: $0 {start|stop|status}"
;;
"/etc/rc.d/init.d/mpd" 53L, 1411C